package com.heima.comment.controller;

import com.heima.comment.service.CommentService;
import com.heima.comment.user.dtos.ApCommentLikeDto;
import com.heima.comment.user.dtos.ApCommentSaveDto;
import com.heima.comment.user.dtos.ApCommentSearchDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
@RequiredArgsConstructor
public class CommentController {

    private final CommentService commentService;

    /**
     * 保存评论
     * @param saveDto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody ApCommentSaveDto saveDto){
        return commentService.saveComment(saveDto);
    }

    /**
     * 查询评论列表
     * @param searchDto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult loadComment(@RequestBody ApCommentSearchDto searchDto){
        return commentService.loadComment(searchDto);
    }

    /**
     * 评论点赞
     * @param likeDto
     * @return
     */
    @PostMapping("/like")
    private ResponseResult likeComment(@RequestBody ApCommentLikeDto likeDto){
        return commentService.likeComment(likeDto);
    }
}
